home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* HELP command *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- {$UNDEF help_bug}
-
- UNIT BBHELP;
-
- INTERFACE
-
- PROCEDURE help_cmd(cmd_string : STRING);
-
- IMPLEMENTATION
-
- USES
- CRT,
- bbdummy,
- bbmdata,
- bbmess,
- bbmisc,
- bbmisc5,
- bbsdata,
- bbstr,
- bbuf,
- bbwin,
- match;
-
- (*===========================================================================*)
- (* HELP command *)
- (*===========================================================================*)
-
- PROCEDURE help_cmd(cmd_string : STRING);
-
- VAR
- found : BOOLEAN;
- help_f : TEXT;
- i : WORD;
- t_str : STRING;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Remove blanks *)
- (*-----------------------------------------------------------------------*)
-
- strip_crlf(cmd_string);
-
- (*-----------------------------------------------------------------------*)
- (* Validate command *)
- (*-----------------------------------------------------------------------*)
-
- IF (LENGTH(cmd_string) > 1) AND (cmd_string[2] <> ' ') THEN
- BEGIN;
- send_message(message_err_2nd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF words(cmd_string) > 2 THEN
- BEGIN;
- send_message(message_err_wrd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Get the thing to look for *)
- (*-----------------------------------------------------------------------*)
-
- IF words(cmd_string) = 1 THEN
- cmd_string := '_'
- ELSE
- cmd_string := subword(@cmd_string, 2, 1);
-
- (*-----------------------------------------------------------------------*)
- (* Construct file name to use based on user's language *)
- (*-----------------------------------------------------------------------*)
-
- t_str := opt_block.help_fn;
-
- i := POS(active_tcb^.uid_data.user_lang, opt_block.language_list);
-
- IF i = 0 THEN
- i := POS(active_port^.dflt_lang, opt_block.language_list);
-
- IF i > 1 THEN
- t_str := t_str + opt_block.language_list[i];
-
- (*-----------------------------------------------------------------------*)
- (* Attempt to open the file *)
- (*-----------------------------------------------------------------------*)
-
- ASSIGN(help_f, t_str);
-
- {$I-}
- RESET(help_f);
- {$I+}
-
- i := IORESULT;
-
- (*-----------------------------------------------------------------------*)
- (* If we couldn't open the help file and the language feature is in *)
- (* use then switch back to the master help file *)
- (*-----------------------------------------------------------------------*)
-
- IF (i <> 0) AND (t_str <> opt_block.help_fn) THEN
- BEGIN;
-
- ASSIGN(help_f, opt_block.help_fn);
-
- {$I-}
- RESET(help_f);
- {$I+}
-
- i := IORESULT;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* File won't open *)
- (*-----------------------------------------------------------------------*)
-
- IF i <> 0 THEN
- BEGIN;
- send_tnc_data_str(dos_err_message(i));
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Assume we haven't found anything yet *)
- (*-----------------------------------------------------------------------*)
-
- found := FALSE;
-
- upcase_str_var(cmd_string);
-
- {$IFDEF help_bug}
- WRITELN('HELP=', LENGTH(cmd_string), '=', cmd_string);
- {$ENDIF}
-
- WHILE (NOT found) AND (NOT EOF(help_f)) DO
- BEGIN;
- READLN(help_f, t_str);
- IF t_str[1] = ':' THEN
- BEGIN;
-
- {$IFDEF help_bug}
- WRITELN('TSTR=', LENGTH(t_str), '=', t_str);
- WRITELN('TSTR2=', LENGTH(SUBWORD(@t_str, 2, 1)) , '=',
- SUBWORD(@t_str, 2, 1));
- WRITELN('TSTR3=', match_str(cmd_string, SUBWORD(@t_str, 2, 1)));
- DELAY(1000);
- {$ENDIF}
-
- IF words(t_str) <> 3 THEN
- window_write_critical('HELP:> Bad help file line --', t_str)
- ELSE
- IF match_str(cmd_string, SUBWORD(@t_str, 2, 1)) THEN
- BEGIN;
-
- t_str := subword(@t_str, 3, 1);
-
- i := POS(t_str[1], user_class_string);
-
- {$IFDEF help_bug}
- WRITELN('USER=', LENGTH(t_str), '=', t_str, '=', i);
- DELAY(1000);
- {$ENDIF}
-
- IF i > 0 THEN
- DEC(i);
- IF i <= ORD(active_tcb^.uid_data.user_class) THEN
- found := TRUE;
-
- END;
- END;
- END;
-
- IF (NOT found) OR EOF(help_f) THEN
- BEGIN;
- CLOSE(help_f);
- send_message(message_help_nf);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- WHILE NOT EOF(help_f) DO
- BEGIN;
- READLN(help_f, t_str);
- IF (LENGTH(t_str) > 0) AND (t_str[1] = ':') THEN
- BEGIN;
- CLOSE(help_f);
- EXIT;
- END;
- send_tnc_data_str(t_str + cr);
- END;
-
- CLOSE(help_f);
-
- END;
-
- END.